Aligning Windows
This section describes the functions that allow your application to position and drag windows to optimal screen positions based on the depth of the screen. These functions are useful for movie playback performance considerations that depend on where you draw on the screen.
The Image Compression Manager places the windows at an optimal position on the screen by aligning rectangles horizontally on 1-bit and 2-bit screens to multiples of 16 pixels, aligning 4-bit screens to multiples of 8, aligning 8-bit screens to multiples of 4, and aligning 16-bit screens to multiples of 2. (Alignment on 32-bit screens is to multiples of 4 pixels and only occurs on Macintosh computers of class 68040 or greater.) When the alignment rectangle crosses more than one screen, the Image Compression Manager uses the alignment of the strictest screen.
Decompression to non-optimally aligned destinations can reduce performance by as much as 50 percent, so you should use these functions whenever possible.
The alignment behavior provided by these functions is adequate in the vast majority of situations. However, if you need customized alignment behavior (for example, justification specifications geared to particular video hardware), you can use the application-defined function described in
"Alignment Functions"
to override the standard alignment. See the chapter "Sequence Grabber Components" in
Inside Macintosh: QuickTime Components
for more information on application-defined alignment functions and video hardware. All the alignment functions provide a parameter in which you can specify a function with customized alignment behavior.
The
AlignWindow
function enables you to transport a specified window to the nearest optimal alignment position. The
DragAlignedWindow
function drags the specified window along an optimal alignment grid. The
DragAlignedGrayRgn
function drags a specified gray region along an optimal alignment grid. The
AlignScreenRect
function aligns a specified rectangle to the strictest screen that the rectangle intersects.
AlignWindow
The
AlignWindow
function moves a specified window to the nearest optimal alignment position.
pascal void AlignWindow (WindowPtr wp, Boolean front,
const Rect *alignmentRect,
ICMAlignmentProcRecordPtr alignmentProc);
-
wp
-
Points to the window to be aligned.
-
front
-
Specifies the frontmost window. If the front parameter is
true
and the window specified in the
wp
parameter isn't the active window,
AlignWindow
makes it the active window by calling the Window Manager's
SelectWindow
routine.
-
alignmentRect
-
Contains a pointer to a rectangle in window coordinates that allows you to align the window to a rectangle within the window. Set this parameter to
nil
to align using the bounds of the window.
-
alignmentProc
-
Points to a function that allows you to provide your own alignment behavior. Set this parameter to
nil
to use the standard behavior. Your alignment function must be in the following form:
-
pascal void MyAlignmentProc(Rect *rp, long refcon);
See
"Alignment Functions"
for details.
SEE ALSO
The
AlignWindow
function is similar to the Window Manager's
MoveWindow
routine. See
Inside Macintosh: Macintosh Toolbox
Essentials
for details.
DragAlignedWindow
The
DragAlignedWindow
function drags the specified window along an optimal alignment grid.
pascal void DragAlignedWindow (WindowPtr wp, Point startPt,
Rect *boundsRect,
Rect *alignmentRect,
ICMAlignmentProcRecordPtr alignmentProc);
-
wp
-
Contains a window pointer to the window to be dragged.
-
startPt
-
Specifies a point that is equal to the point where the mouse button was pressed (in global coordinates, as stored in the
where
field of the event structure).
DragAlignedWindow
pulls a gray outline of the window around the screen, following the movements of the mouse until the button is released.
-
boundsRect
-
Points to the boundary rectangle in global coordinates. If the mouse button is released when the mouse position is outside the limits of the boundary rectangle,
DragAlignedWindow
returns without moving the window or making it the active window. For a document window, the boundary rectangle typically is four pixels in from the menu bar and from the other edges of the screen, to ensure that there won't be less than a four-pixel-square area of the title bar visible on the screen.
-
alignmentRect
-
Points to a rectangle in window coordinates that allows you to align the window to a rectangle within the window. Set this parameter to
nil
to align using the bounds of the window.
-
alignmentProc
-
Allows you to provide your own alignment behavior. Set this parameter to
nil
to use the standard alignment behavior. Your alignment function must be in the following form:
-
pascal void MyAlignmentProc (Rect *rp, long refcon);
See
"Alignment Functions"
for details.
SEE ALSO
The
DragAlignedWindow
is similar to the Window Manager's
DragWindow
routine. See
Inside Macintosh: Macintosh Toolbox Essentials
for details on
DragWindow
.
DragAlignedGrayRgn
The
DragAlignedGrayRgn
function drags the specified gray region along an optimal alignment grid.
pascal long DragAlignedGrayRgn (RgnHandle theRgn, Point startPt,
Rect *boundsRect, Rect *slopRect,
short axis, UniversalProcPtr actionProc,
Rect *alignmentRect,
ICMAlignmentProcRecordPtr alignmentProc);
-
theRgn
-
Contains a region handle to the specified region for this operation. When the user holds down the mouse button,
DragAlignedGrayRgn
pulls a gray outline of the region around following the movement of the mouse until the mouse button is released.
-
startPt
-
Specifies the point where the mouse button was originally pressed in the local coordinates of the current graphics port.
-
boundsRect
-
Contains a pointer to the boundary rectangle of the current graphics port. The offset point follows the mouse location except that
DragAlignedGrayRgn
never moves the offset point outside this rectangle. This limits the travel of the region's outline, not the movements of the mouse.
-
slopRect
-
Contains a pointer to the
slop
rectangle that completely encloses the boundary rectangle so that the user is allowed some flexibility in moving the mouse.
-
axis
-
Allows you to constrain the region's motion to only one axis. Set this parameter to 0 to specify no constraint. To indicate constraint along a horizontal axis, set this parameter to 1. To indicate constraint along a vertical axis, set this parameter to 2. See
Inside Macintosh: Macintosh Toolbox Essentials
for details on the constants for the axis parameter of the Window Manager's
DragGrayRgn
routine.
-
actionProc
-
Points to a function that defines some action to be performed repeatedly as long as the user holds down the mouse button. The function should have no parameters. If the
actionProc
parameter is
nil
,
DragAlignedGrayRgn
simply retains control until the mouse button is released.
-
alignmentRect
-
Contains a pointer to a rectangle within the bounds of the region specified in the parameter
theRgn
. Pass
nil
to align using the bounds of the parameter
theRgn
.
-
alignmentProc
-
Points to your own alignment behavior function. Pass
nil
to use the standard behavior. Your alignment function must be in the following form:
-
pascal void MyAlignmentProc (Rect *rp, long refcon);
See
"Alignment Functions"
for details.
DESCRIPTION
The
DragAlignedGrayRgn
function is not normally made directly. The
DragAlignedWindow
function (described on
DragAlignedWindow
) calls this function.
SEE ALSO
The
DragAlignedGrayRgn
function is nearly identical to the Window Manager's
DragGrayRgn
routine. See
Inside Macintosh: Macintosh Toolbox Essentials
for details on
DragGrayRgn
.
AlignScreenRect
The
AlignScreenRect
function aligns a specified rectangle to the strictest screen that the rectangle intersects.
pascal void AlignScreenRect (Rect *rp,
ICMAlignmentProcRecordPtr alignmentProc);
-
rp
-
Contains a pointer to a rectangle defined in global screen coordinates.
-
alignmentProc
-
Points to your own alignment behavior function. Set this parameter to
nil
to use the standard behavior. Your alignment function must be in the following form:
-
pascal void MyAlignmentProc (Rect *rp, long refCon);
See
"Alignment Functions"
for details.
DESCRIPTION
Normally, the
AlignScreenRect
function is not called directly.
© 1999 Apple Computer, Inc.Previous | Overview | Contents | Next